
import React, { Component } from 'react';
import PropTypes from 'prop-types'

class Parent9 extends Component {
    state = {}
    render() {
        return (<div>
            <Child9 colors={19}></Child9>
        </div>);
    }
}

export default Parent9;

class Child9 extends Component {
    state = {}
    render() {
        // colors : ['red','blue']
        return (<div>
            {
                this.props.colors.map(item => (<span key={item}>{item}</span>))
            }
        </div>);
    }
}

// 1.0 给Child9 中的props.colors增加校验规则
// 给props中的colors属性增加一个类型校验，类型为array
Child9.propTypes = {
    colors: PropTypes.array.isRequired
}